<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script language="Javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/paging.js"></script>

<script language="JavaScript">
	$(document).ready(function() {
		$("#allsts").change(function() {
			var isChecked = $('.selsts').attr('checked') ? true : false;
			if (isChecked == false) {
				$(".selsts").attr('checked', true);
			} else {
				$(".selsts").attr('checked', false);
			}

		});

		$('#search').keyup(function() {
			searchTable($(this).val());
		});

		$("#example").tablesorter({
			// pass the headers argument and assing a object 
			headers : {
				// assign the secound column (we start counting zero) 
				6 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				// assign the third column (we start counting zero) 
				7 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				8 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				9 : {
					// disable it by setting the property sorter to false 
					sorter : false
				},
				0 : {
					// disable it by setting the property sorter to false 
					sorter : false
				}
			}
		});
	});

	function searchTable(inputVal) {
		var table = $('#example');
		table.find('tr').each(function(index, row) {
			var allCells = $(row).find('td');
			if (allCells.length > 0) {
				var found = false;
				allCells.each(function(index, td) {
					var regExp = new RegExp(inputVal, 'i');
					if (regExp.test($(td).text())) {
						found = true;
						return false;
					}
				});
				if (found == true)
					$(row).show();
				else
					$(row).hide();
			}
		});
	}
</script>
<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
function reload(){
	window.location.href=window.location.href;
}
</script>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
	<div align="left">
	<s:actionerror />
	</div>
	<div align="right">Search Entries:<input type="text" id="search" /></div>
			<div align="left">
				<a href="javascript:void(0);" onclick="PopupCenter('admin/UploadHostelExcel.jsp','batch',300,300);">Upload a Hostel Excel Sheet</a>
				<br/><a href="javascript:void(0);" onclick="PopupCenter('admin/UploadRoomExcel.jsp','batch',300,300);">Upload a Room Excel Sheet</a>
			</div>
		<form id="form" action="deletehostel.action" method="post">
	<table id="example" class="tablesorter" width="100%">
		<thead>
		<tr>
		<th><input type="checkbox" id="allsts" /></th>
			<th>residential_id</th>
			<th>residential_name</th>
			<th>residential_type</th>
			<th>capacity</th>
			<th>warden_id</th>
			<th>warden_name</th>
			<th>Occupied Rooms</th>
			<th>All Rooms</th>
			<th>EDIT</th>
			<th>DELETE</th>
		</tr>
		</thead>
		<tbody>
		<s:iterator value="hostelList">
			<tr>
			<td><input type="checkbox" class="selsts" value='<s:property value="residential_id" />' name="residential_id"/></td>
				<td><s:property value="residential_id" /></td>
				<td><s:property value="residential_name" /></td>
				<td><s:property value="residential_type" /></td>
				<td><s:property value="capacity" /></td>
				<td><s:property value="warden_id" /></td>
				<td><s:property value="warden_name" /></td>
				<td><a href="hostelstudents.action?residential_id=<s:property value="residential_id"/>">Show occupied rooms</a>
				<td><a href="hostelrooms.action?residential_id=<s:property value="residential_id"/>">Show all rooms</a>
				<td><a href="editHostelDetails.action?residential_id=<s:property value="residential_id"/>&type=gethosteldetails">EDIT</a></td>
				<td><a href="deletehostel.action?residential_id=<s:property value="residential_id"/>">DELETE</a></td>
		</s:iterator>
			<tr>
				<td><input type="submit" value="Delete Selected Hostels"/></td>
			</tr>
		</tbody>
	</table>
	</form>
	<a href="editHostelDetails.action?type=addnewhostel">Add a new Hostel</a>
</body>
</html>